﻿using LiteBlog.Common.Entities;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace LiteBlog.Controllers.Helpers
{
    class DisplayHelper
    {
        internal static readonly string ShortDateFormat = "dd-MMM-yyyy";
        internal static readonly string CalendarDateFormat = "MM/dd/yyyy";
        internal static readonly string LongDateFormat = "dd-MMM-yyyy hh:mm tt";

        internal static void SetDisplayTime(Post post)
        {
            post.FormattedTime = post.Time.ToString(ShortDateFormat, CultureInfo.InvariantCulture);
            if (post.UpdatedTime >= post.Time)
                post.FormattedUpdatedTime = post.UpdatedTime.ToString(LongDateFormat, CultureInfo.InvariantCulture);
            else
                post.FormattedUpdatedTime = post.FormattedTime;
            foreach (var c in post.Comments)
                c.FormattedTime = c.Time.ToString(LongDateFormat, CultureInfo.InvariantCulture);
        }
    }
}
